import time


class Person:
    name = "人类"
    age = 0
    sex = None

# 类
# 1.通过对象间接查询 实例化创建对象
print(Person().name)
print(Person().age)
print(Person().sex)
# 2.通过类名直接查询
print(Person.name)
print(Person.age)
print(Person.sex)

# 添加类属性 ;  类名.新属性 = 属性值
# Person.height = 100
# 修改类属性
Person.name="牛批的人类"
# 删除类属性
# del Person.name
print(Person.name)

fyx = Person()
lf = Person()
print(fyx.name,fyx.age,fyx.sex)
print(lf.name,lf.age,lf.sex)
# 对 对象 属性进行  添加属性 修改属性
fyx.name="付雅馨"
fyx.age = 19
fyx.sex = "女"
fyx.balance = 1000000000000
print(fyx.name,fyx.age,fyx.sex,fyx.balance)
print(lf.name,lf.age,lf.sex)

# del fyx.age
# print(fyx.name,fyx.age,fyx.sex,fyx.balance)


class Humanity(object):
    name="人类"

    # 实例方法
    def selfReported(self,deposit):
        print("我叫",self.name,",我是亿万富翁,我摊牌了,我有{}".format(deposit))

    def fallInLove(self,someone):
        print("我在和",someone,"谈恋爱!")

    # 类方法
    @classmethod
    def a(cls):
        print(cls.name)

    # 静态方法
    @staticmethod
    def fun():
        print("这里是静态方法")

    def __del__(self):
        print("Humanity没了")

lzh = Humanity()
lzh.name="刘子涵"
lzh.fallInLove("xxx")
fyx = Humanity()

# lzh.a()
# Humanity.a()

print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
class A:
    # def __new__(cls, *args, **kwargs):
    #     """
    #     创建
    #     :param args:
    #     :param kwargs:
    #     """
    #     print("我被创建出来了!!")

    def __init__(self,value):
        """
        初始化
        """
        self.myValue = value

    def __del__(self):
        print("我没了")



del lzh
a = A("123")
print(a.myValue)
print(a.myValue)
print(a.myValue)
print(a.myValue)
print(a.myValue)
print(a.myValue)





class Car(object):
    name="汽车类"
    licensePlate = "FUCK123"
    __color="粉色"  # 私有的
    price = 1000000

    def fun1(self):
        print(self.name)

    def fun3(self):
        self.__color = "red"

    @classmethod
    def fun2(cls):
        print(cls.name)

# 继承
class RollsRoyce(Car):
    name = "劳斯莱斯"
    licensePlate = "FUCK66666"
    price = 1000000000000

    # 属性和方法全部公有
    def fun1(self):
        print(self.name)

    @classmethod
    def fun2(cls):
        print(cls.name)

Car().fun1()
RollsRoyce().fun1()


